#ifndef	dx10StateUtils_included
#define	dx10StateUtils_included
#pragma once

namespace dx10StateUtils
{
	D3D10_CULL_MODE			ConvertCullMode(D3DCULL Mode);
	D3D10_COMPARISON_FUNC	ConvertCmpFunction(D3DCMPFUNC Func);
	D3D10_STENCIL_OP		ConvertStencilOp(D3DSTENCILOP Op);
	D3D10_BLEND				ConvertBlendArg(D3DBLEND Arg);
	D3D10_BLEND_OP			ConvertBlendOp(D3DBLENDOP Op);
	D3D10_TEXTURE_ADDRESS_MODE	ConvertTextureAddressMode(D3DTEXTUREADDRESS Mode);


	//	Set description to default values
	void	ResetDescription( D3D10_RASTERIZER_DESC &desc );
	void	ResetDescription( D3D10_DEPTH_STENCIL_DESC &desc );
	void	ResetDescription( D3D10_BLEND_DESC &desc );
	void	ResetDescription( D3D10_SAMPLER_DESC &desc );

	//	State comparison (memcmp doesn't work due to padding bytes in structure)
	bool	operator==(const D3D10_RASTERIZER_DESC &desc1, const D3D10_RASTERIZER_DESC &desc2);
	bool	operator==(const D3D10_DEPTH_STENCIL_DESC &desc1, const D3D10_DEPTH_STENCIL_DESC &desc2);
	bool	operator==(const D3D10_BLEND_DESC &desc1, const D3D10_BLEND_DESC &desc2);
	bool	operator==(const D3D10_SAMPLER_DESC &desc1, const D3D10_SAMPLER_DESC &desc2);

	//	Calculate hash values
	u32		GetHash( const D3D10_RASTERIZER_DESC &desc );
	u32		GetHash( const D3D10_DEPTH_STENCIL_DESC &desc );
	u32		GetHash( const D3D10_BLEND_DESC &desc );
	u32		GetHash( const D3D10_SAMPLER_DESC &desc );

	//	Modify state to meet DX10 automatic modifications
	void	ValidateState(D3D10_RASTERIZER_DESC &desc);
	void	ValidateState(D3D10_DEPTH_STENCIL_DESC &desc);
	void	ValidateState(D3D10_BLEND_DESC &desc);
	void	ValidateState(D3D10_SAMPLER_DESC &desc);
};

#endif	//	dx10StateUtils_included